package com.josework.springhelloworld.utils;

import java.util.Arrays;
import java.util.List;

public class Debugging {
    public static void main(String[] args) {

        List<Integer> nums = Arrays.asList(2,4,5,6,7);
//        nums.stream()
//                .map(Debugging::divideByZero).forEach(System.out::println);
        nums.stream()
                .peek(x -> System.out.println("from stream: "+x))
                .map(Debugging::addValue)
                .peek(x -> System.out.println("after map: "+x))
                .filter( x -> x % 2==0)
                .peek( x -> System.out.println("after filter: "+x))
                .limit(3)
                .peek(x -> System.out.println("after limit: "+x))
                .forEach(System.out::println);

    }
    public static int addValue(int n){
        return  n + 17;
    }

    public static int divideByZero(int n){
        return n / 0;
    }
}
